/**
 * @author ciwyaitd
 * @date   15/11/15
 * @description []
 */
$(function(){
	//var currentWidth = 0;
	//$(window).resize(function(event) {
	//	if($(window).width() == currentWidth) return;
	//	currentWidth = $(window).width();
	//	$('body').css('height', $(window).height());
	//});
	//$(window).resize();

    var color_ary = ['green-bg-color','yellow-bg-color','back-bg-color','pink-bg-color','blue-bg-color'],
        random_num = ~~(Math.random()*5);
    $('.bg-color').addClass(color_ary[random_num]);


	$('.J_Lucky_btn').click(function(){
		var user_name = $('#username').val(),
			date = $('#date').val(),
			hour = $('#hour').val(),
			sex = $('input[name="radio1"]:checked').val(),
			date_type = $('input[name="radio2"]:checked').val(),
			bowser_version = window.navigator.userAgent.toLowerCase(),
			date_year, date_month, date_day, date_hour;

		$.browser = {
			version: (bowser_version.match( /version\/([^\/*$\/]+)/i ) || bowser_version.match( /Gecko\/([^\/*$\/]+)/i ) || [])[1],
			safari: /webkit/.test( bowser_version ),
			opera: /opera/.test( bowser_version ),
			msie: /msie/.test( bowser_version ) && !/opera/.test( bowser_version ),
			mozilla: /mozilla/.test( bowser_version ) && !/(compatible|webkit)/.test( bowser_version )
		};
		for(var key in $.browser){
			if( $.browser[key] ){
				bowser_version = $.browser['version'] + ' ' + key;
			}
		}

		// bowser_version = window.navigator.userAgent.match(/version\/([^\/*$\/]+)/i)[1]
		//if( user_name == '' ){
		//	alert('大虾, 留下你的大名吧.')
		//	return ;
		//}

		date_year = date.substr(0, 4),
		date_month = date.substr(5, 2),
		date_day = date.substr(8, 2),
		date_hour = hour.substr(0, 2);

		window.location.href = 'http://115.29.185.67/web/html/testResult.jsp?year=' + date_year +'&month=' +date_month +'&day=' + date_day
							+ '&hour=' + date_hour + '&sex='+ sex + '&li='+ date_type + '&name=' + user_name
							+ '&bowser=' + bowser_version + '&openid=2456';
	});


});